﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <script>
        var ws = undefined;
        window.onload = function () {
            ws = new WebSocket("ws://192.168.1.128:40131");
            window.g_ws = ws;
            ws.onmessage = function (msg) {
                console.log("response: len = " + msg.data.toString().length);
                
            }
            ws.onerror = function (data) {
                console.log(data.error);
            }
            ws.onclose = function (data) {
                console.log(data.code);
            }
            ws.onopen = function (data) {
                console.log(data);
            }
        };
        function t_click() {
            //ws.send("abc");
            var datastr = document.getElementById("msg").value;
            console.log("request: len = " + datastr.length);
            ws.send(datastr);
        }
        function t_reconnect() {
            ws = new WebSocket("ws://192.168.1.128:40131");
            ws.onmessage = window.g_ws.onmessage;
            ws.onerror = window.g_ws.onerror;
            ws.onclose = window.g_ws.onclose;
            ws.onopen = window.g_ws.onopen;
        }
    </script>
</head>
<body>
    <textarea style="width:497px; height:523px;" id="msg">

    </textarea>
    <div>
        <input type="button" style="float:right;" onclick="t_click();"  value="发送" />
        <input type="button" style="float:right;" onclick="t_reconnect();" value="重连" />
    </div>
</body>
</html>
